/**
 *
 * © Bahadir Zeren 2011
 * bzeren@gmail.com
 * No warranties, express or implied, are made for this program.
 *
 */
package org.baatar.opt.genetic.crossover;

import java.io.Serializable;
import org.baatar.opt.genetic.chromosome.IChromosome;
import org.baatar.util.RandomUtil;

/**
 * Interface for the crossover operators.
 * 
 * @author Ba
 */
public interface ICrossoverOperator<T, M> extends Serializable, Cloneable {
    /**
     * Performs crossover operation according to the algorithm in the 
     * implementing class.
     * 
     * @param population list of whole population.
     * @param startingChildIndex starting index for newly generated children.
     * @param mother first candidate of the crossover operation.
     * @param father second candidate of the crossover operation.
     * @param worstFitness the worst fitness value of the current population.
     * @param random Randomization class to be used.
     * 
     * @return last free index of children list.
     * 
     * @throws CloneNotSupportedException is trown if chromosome objects do not
     * implement Cloneable interface
     */
    public int crossover(IChromosome<T, M> population[],
                            int startingChildIndex,
                            IChromosome<T, M> mother,
                            IChromosome<T, M> father,
                            double worstFitness,
                            RandomUtil random) throws CloneNotSupportedException;

    /**
     * Clones the this object.
     * 
     * @return Object new cloned object.
     * 
     * @throws CloneNotSupportedException is trown if this object doesnt
     * implements Cloneable interface.
     */
    public Object clone() throws CloneNotSupportedException;
}
